<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<link th:href="@{/css/bootstrap.min.css}" rel="stylesheet"  />
	<link th:href="@{/css/font-awesome.min.css}" rel="stylesheet"  />
	<!-- bootstrap-table 表格插件样式 -->
	<link th:href="@{/ajax/libs/bootstrap-table/bootstrap-table.min.css}" rel="stylesheet"/>
	<link th:href="@{/css/animate.css}" rel="stylesheet"  />
	<link th:href="@{/css/style.css}" rel="stylesheet" />
	<link th:href="@{/ruoyi/css/ry-ui.css}" rel="stylesheet"  />
	<th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg" >
	<form class="form-horizontal m-t"  id="signupForm" th:object="${appFrom}">
		<input class="form-control" type="hidden"  name="taskId" th:value="${taskId}"/>
		<input class="form-control" type="hidden" id="processInstanceId"  th:value="${processInstanceId}"/>
		<input class="form-control" type="hidden"  name="businessKey" th:value="${appFrom.resignNo}"/>
		<input name="id" th:value="${appFrom.id}" type="hidden">
	    <br/>
		<h2 class="form-header h2" >离职审批信息</h2>
		<div class="form-group">
			<label class="col-sm-3 control-label">离职单号：</label>
			<div class="col-sm-8">
				<input name="resignNo" th:field="*{resignNo}" class="form-control" type="text">
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">离职类型：</label>
			<div class="col-sm-8">
				<select name="resignType" class="form-control m-b" th:with="type=${@dict.getType('sys_resign_type')}">
					<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{resignType}"></option>
				</select>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">离职标题：</label>
			<div class="col-sm-8">
				<input name="name" th:field="*{name}" class="form-control" type="text">
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">离职理由：</label>
			<div class="col-sm-8">
				<textarea name="reason" class="form-control">[[*{reason}]]</textarea>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">离职去向：</label>
			<div class="col-sm-8">
				<input name="resignPlaceGo" th:field="*{resignPlaceGo}" class="form-control" type="text">
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">交接人：</label>
			<!--<div class="col-sm-8">
				<input name="transitionPerson" th:field="*{transitionPerson}" class="form-control" type="text">
			</div>-->
			<div class="col-sm-8">
				<div class="input-group">
					<input class="form-control" type="hidden" name="transitionPerson"  id="transitionPerson" th:field="*{transitionPerson}">
					<input class="form-control" type="text" name="transitionPersonName" th:field="*{transitionPersonName}" onclick="selectUserInfo()" id="transitionPersonName" readonly="true">
					<span class="input-group-addon"><i class="fa fa-search"></i></span>
				</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">离职时间：</label>
			<div class="col-sm-8">
				<div class="input-group date">
					<input name="resignTime" th:value="${#dates.format(appFrom.resignTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
					<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
				</div>
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-3 control-label">附件：</label>
			<div class="col-sm-8">
				<input type="hidden" name="fileUrl" th:field="*{fileUrl}">
				<div class="file-loading">
					<input class="form-control file-upload" id="fileUrl" name="file" type="file">
				</div>
			</div>
		</div>
    <br/>
		<th:block th:include="include :: approvalpage" />
	</form>
    <th:block th:include="include :: footer" />
	<th:block th:include="include :: bootstrap-fileinput-js"/>
    <script th:inline="javascript">
        $(function () {
            var processInstanceId= $("#processInstanceId").val();
            var url ="/modeler/getProcessDiagram?processInstanceId="+processInstanceId;
            $(".imgcode").attr("src", url);
        });
        var files=new Array();
        $(".file-upload").each(function (i) {
            var val = $("input[name='" + this.id + "']").val();
            $(this).fileinput({
                'uploadUrl': '/common/upload',
                initialPreviewAsData: true,
                allowedFileExtensions: ['jpg', 'gif', 'png',".docx","doc","ppt","pptx","xls","xlsx","vsd","rtf","wps","pdf","txt"],//接收的文件后缀
                initialPreview: [val],
                maxFileCount: 1,
                autoReplace: true
            }).on('fileuploaded', function (event, data, previewId, index) {
                files.push({"key": data.response.fileKey,"name": data.response.fileName, "url":data.response.url});
               // $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('')
            })
            $(this).fileinput('_initFileActions');
        });

        <!--提交审核结果-->
        function submitCheckHandler() {
            if ($.validate.form()) {
                var data = $("#signupForm").serializeArray();
                for(var i=0;i<data.length;i++){
                    if(data[i].name=='comment'&&(data[i].value==''||data[i].value==null)){
                        $.modal.alertError("请填写审批意见");
                        return false;
					}
				}
				if(files!=null||files!=''){
                    for(var i=0;i<files.length;i++){
                        data.push({"name": "files["+i+"].key", "value":files[i].key});
                        data.push({"name": "files["+i+"].name", "value":files[i].name});
                        data.push({"name": "files["+i+"].url", "value":files[i].url});
                    }
				}
                $.operate.saveTab("/system/resign/restart", data);
            }
        }

        /*选择用户*/
        function selectUserInfo() {
            var url = "/system/resign/selectUser";
            $.modal.open("选择用户",url,"","",doSubmit);
        }

        function doSubmit(index, layero){
            var body = layer.getChildFrame('body', index);
            var iframeWin = layero.find('iframe')[0];
            iframeWin.contentWindow.submitHandler(index, layero);
            $("#transitionPerson").val(body.find('#id').val());
            $("#transitionPersonName").val(body.find('#userName').val());
            layer.close(index);
        }
    </script>
</body>
</html>